<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>可可商城-用户协议</title>
  <link rel="stylesheet" href="./iconfont.css">
  <link rel="stylesheet" href="./modal.css">
  <style>
    .m-modal__body {
      overflow-x: hidden;
      overflow-y: auto;
    }

    .my-content {
      font-size: 12px;
      line-height: 22px;
    }

    * {
      font-size: 12px;
      margin: 0px;
      padding: 0px;
    }
  </style>

</head>
<div>
  <div style="font-size: 16px; font-weight: bold; line-height: 50px; height: 50px; text-align: center;">
    《可可商城-用户协议》和《可可商城-隐私协议》
  </div>
  <div style="font-size: 14px; line-height: 25px;  width: 95%; margin: 0px auto;margin-top: 20px; text-indent: 30px;">
    请你务必审慎阅读、充分理解<a href="javascript:void(0)" onclick="showContent('AppAgreement')">《可可商城-用户协议》</a>和<a href="javascript:void(0)" onclick="showContent('AppAgreement')">《可可商城-隐私协议》</a>各条款，包括但不限于：为了更好的向你提供服务，我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。
  </div>
</div>
<div
  style="width: 100%; line-height: 35px; height: 35px; position: fixed; bottom: 0px; background: rgba(0,0,0,.3); text-align: center">
  <button class="m-modal-button m-modal--primary" onclick="myConfirm(1)"><span>同意</span></button>
  <button class="m-modal-button m-modal--danger" onclick="myConfirm(0)"><span>拒绝</span></button>
</div>

<body>
<script src="./jquery-1.10.2.min.js"></script>
<script src="./modal.js"></script>
<script src="./data.js"></script>
<script>
  function myConfirm (is) {
    if (is===0) {
      plus.runtime.quit()
      return
    }
    localStorage.setItem('AppAgreement', '1')
    localStorage.setItem('PrivacyAgreement', '1')
    location.replace('/')
  }

  function showContent(key){
    var nameMap={
      AppAgreement:'可可商城-用户协议',
      PrivacyAgreement:'可可商城-隐私协议',
    }
    var mModal1 = new mModal({
      title: nameMap[key],
      confirmText: '返回',
      // cancelText: '拒绝',
      content: '<div class=\'my-conetnt\' style=\'height: ' + (window.getWinSize().height - 130) + 'px;\'>' + window.Agreement[key] + '</div>',
      confirm: function () {
        // localStorage.setItem('PrivacyAgreement', '1')
        // if (window.location.search.substring(1) === 'openPrivacyAgreement') {
        //   localStorage.setItem('AppAgreement', '1')
        //   if (localStorage.getItem('currHref')) {
        //     window.location.replace(localStorage.getItem('currHref'))
        //   }
        //   return
        // }
        // $('#checkbox').attr('checked', true)
        mModal1.close()
      },
      cancel: function () {
        // plus.runtime.quit()
      }
    })

    mModal1.renderDom()
  }

  $(function () {

    var mModal2 = new mModal({
      title: '可可商城-用户隐私协议',
      // confirmText: '同意',
      // cancelText: '拒绝',
      content: '<div class=\'my-conetnt\' style=\'height: ' + (window.getWinSize().height - 150) + 'px;\'>' + window.Agreement.PrivacyAgreement + '</div>',
      confirm: function () {
        localStorage.setItem('PrivacyAgreement', '1')
        if (window.location.search.substring(1) === 'openPrivacyAgreement') {
          localStorage.setItem('AppAgreement', '1')
          if (localStorage.getItem('currHref')) {
            window.location.replace(localStorage.getItem('currHref'))
          }
          return
        }
        $('#checkbox').attr('checked', true)
        mModal2.close()
      },
      cancel: function () {
        // plus.runtime.quit()
      }
    })

    $('#PrivacyAgreement').on('click', function () {
      mModal2.renderDom()
    })

    if (window.location.search.substring(1) === 'openPrivacyAgreement') {
      mModal2.renderDom()
    }
  })





</script>
</body>

</html>
